package com.sample;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;

/**
 * This is a sample class to launch a rule.
 */
public class DroolsTest {
	public static Message message;
    public static final void main(String[] args) {
        try {
            // load up the knowledge base
	        KieServices ks = KieServices.Factory.get();
    	    KieContainer kContainer = ks.getKieClasspathContainer();
        	KieSession kSession = kContainer.newKieSession("ksession-rules");
//        	Map<String, Message> mp = new HashMap<String, Message>();
        	ArrayList<Message> cm = new ArrayList<Message>();
        	cm.add(new Message("hello",Message.HELLO));
            // go !
        	message = new Message();
        	message.setMessage("Hello World");
        	message.setStatus(Message.HELLO);
        	 
           
            
            
            
            kSession.fireAllRules();
            
//            kSession.update(kSession.getFactHandle(message), message2);
//            kSession.fireAllRules();
            
        } catch (Throwable t) {
            t.printStackTrace();
        }
    }

    public static class Message {

        public static final int HELLO = 0;
        public static final int GOODBYE = 1;
        
        private String message;

        private int status;
        
        public Message(){
        	
        }
        
        public Message(String msg,int sta){
        	this.message = msg;
        	this.status = sta;
        }

        public String getMessage() {
            return this.message;
        }

        public void setMessage(String message) {
            this.message = message;
        }

        public int getStatus() {
            return this.status;
        }

        public void setStatus(int status) {
            this.status = status;
        }

    }
    
    public static class Message2 {

        public static final int HELLO = 0;
        public static final int GOODBYE = 1;
        
        private String message;

        private int status;

        public String getMessage() {
            return this.message;
        }

        public void setMessage(String message) {
            this.message = message;
        }

        public int getStatus() {
            return this.status;
        }

        public void setStatus(int status) {
            this.status = status;
        }

    }


}
